package com.prd.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.prd.config.LoginInterceptor;
import com.prd.mapper.EntContactReplyMapper;
import com.prd.model.EntContactReply;
import com.prd.model.LoginUser;
import com.prd.service.EntContactReplyService;
import com.prd.util.UserInfoUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EntContactReplyServiceImpl extends ServiceImpl<EntContactReplyMapper, EntContactReply> implements EntContactReplyService {

    @Autowired
    private EntContactReplyMapper entContactReplyMapper;

    @Override
    public int insertInfo(EntContactReply entContactReply) {
        LoginUser loginUser = LoginInterceptor.threadLocal.get();
        BeanUtils.copyProperties(UserInfoUtil.recordInfo(loginUser.getId(), loginUser.getName(), true), entContactReply);
        return entContactReplyMapper.insert(entContactReply);
    }

    @Override
    public int updateInfo(EntContactReply entContactReply) {
        LoginUser loginUser = LoginInterceptor.threadLocal.get();
        BeanUtils.copyProperties(UserInfoUtil.recordInfo(loginUser.getId(), loginUser.getName(), false), entContactReply);
        return entContactReplyMapper.updateById(entContactReply);
    }
}
